package com.ai.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ai.filter.aop.annotation.LogAnnotation;
import com.ai.service.AiProviderService;
import com.ai.web.PageResp;
import com.ai.web.request.AiProviderAddReq;
import com.ai.web.request.AiProviderPageReq;
import com.ai.web.request.AiProviderUpdateReq;
import com.ai.web.response.AiProviderPageResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/models")
@RestController
@Api(tags = "大模型模块-供应商管理")
public class AiProviderController {

    @Resource
    private AiProviderService aiProviderService;

    @PostMapping("/providers")
    @ApiOperation(value = "分页分页获取供应商列表")
    @SaCheckPermission("models:provider:list")
    @LogAnnotation(title = "供应商管理", action = "分页获取供应商列表")
    public PageResp<AiProviderPageResp> pageInfo(@RequestBody AiProviderPageReq aiProviderPageReq) {
        return aiProviderService.page(aiProviderPageReq);
    }

    @PostMapping("/provider")
    @ApiOperation(value = "添加供应商")
    @SaCheckPermission("models:provider:add")
    @LogAnnotation(title = "供应商管理", action = "添加供应商")
    public void addProvider(@RequestBody AiProviderAddReq aiProviderAddReq) {
        aiProviderService.addProvider(aiProviderAddReq);
    }


    @PutMapping("/provider")
    @ApiOperation(value = "修改供应商")
    @SaCheckPermission("models:provider:update")
    @LogAnnotation(title = "供应商管理", action = "修改供应商")
    public void updateProvider(@RequestBody AiProviderUpdateReq aiProviderUpdateReq) {
        aiProviderService.updateProvider(aiProviderUpdateReq);
    }


    @DeleteMapping("/provider")
    @ApiOperation(value = "删除供应商")
    @SaCheckPermission("models:provider:delete")
    @LogAnnotation(title = "供应商管理", action = "删除供应商")
    public void deleteProvider(@RequestBody @ApiParam(value = "供应商id集合") List<String> providerIds) {
        aiProviderService.deleteProvider(providerIds);
    }

}
